// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: fullnames safe 
// Source File Name:   SourceFile

import java.util.HashMap;
import java.util.List;
import java.util.logging.Logger;
import net.minecraft.server.MinecraftServer;

public class ht extends ee
    implements ea
{

    public ht(net.minecraft.server.MinecraftServer minecraftserver, ay ay1, dv dv1)
    {
        c = false;
        f = 0;
        j = true;
        d = minecraftserver;
        b = ay1;
        ay1.a(((ee) (this)));
        e = dv1;
        dv1.a = this;
	SMPAdmin.getInstance(d); //Just make sure it exists
	// initialize etc!
	etc.getInstance(d);
    }

    public void a()
    {
        b.a();
        if(f++ % 20 == 0)
            b.a(((hh) (new ip())));
    }

    public void c(java.lang.String s)
    {
        b.a(((hh) (new ie(s))));
        b.c();
        d.f.c(e);
        c = true;
    }

    public void a(fz fz1)
    {
        if(!j)
        {
            double d1 = fz1.b - h;
            if(fz1.a == g && d1 * d1 < 0.01D && fz1.c == i)
                j = true;
        }
        if(j)
        {
            g = e.k;
            h = e.l;
            i = e.m;
            double d2 = e.k;
            double d3 = e.l;
            double d4 = e.m;
            float f1 = e.q;
            float f2 = e.r;
            if(fz1.h)
            {
                d2 = fz1.a;
                d3 = fz1.b;
                d4 = fz1.c;
                double d5 = fz1.d - fz1.b;
                if(d5 > 1.6499999999999999D || d5 < 0.10000000000000001D)
                {
                    c("Illegal stance");
                    a.warning((new StringBuilder()).append(e.ap).append(" had an illegal stance: ").append(d5).toString());
                }
                e.ah = fz1.d;
            }
            if(fz1.i)
            {
                f1 = fz1.e;
                f2 = fz1.f;
            }
            e.h();
            e.L = 0.0F;
            e.b(g, h, i, f1, f2);
            double d6 = d2 - e.k;
            double d7 = d3 - e.l;
            double d8 = d4 - e.m;
            float f3 = 0.0625F;
            boolean flag = d.e.a(((df) (e)), e.u.b().e(f3, f3, f3)).size() == 0;
            e.c(d6, d7, d8);
            d6 = d2 - e.k;
            d7 = d3 - e.l;
            if(d7 > -0.5D || d7 < 0.5D)
                d7 = 0.0D;
            d8 = d4 - e.m;
            double d9 = d6 * d6 + d7 * d7 + d8 * d8;
            boolean flag1 = false;
            if(d9 > 0.0625D)
            {
                flag1 = true;
                a.warning((new StringBuilder()).append(e.ap).append(" moved wrongly!").toString());
            }
            e.b(d2, d3, d4, f1, f2);
            boolean flag2 = d.e.a(((df) (e)), e.u.b().e(f3, f3, f3)).size() == 0;
            if(flag && (flag1 || !flag2))
            {
                a(g, h, i, f1, f2);
                return;
            }
            e.v = fz1.g;
            d.f.b(e);
        }
    }

    public void a(double d1, double d2, double d3, float f1, 
            float f2)
    {
        j = false;
        g = d1;
        h = d2;
        i = d3;
        e.b(d1, d2, d3, f1, f2);
        e.a.b(((hh) (new dm(d1, d2 + 1.6200000047683716D, d2, d3, f1, f2, false))));
    }

    public void a(gw gw1)
    {
        boolean flag = d.e.w = d.f.g(e.ap);
        boolean flag1 = false;
        if(gw1.e == 0)
            flag1 = true;
        if(gw1.e == 1)
            flag1 = true;
        if(flag1)
        {
            double d1 = e.l;
            e.l = e.ah;
            fl fl1 = e.a(4D, 1.0F);
            e.l = d1;
            if(fl1 == null)
                return;
            if(fl1.b != gw1.a || fl1.c != gw1.b || fl1.d != gw1.c || fl1.e != gw1.d)
                return;
        }
        int l = gw1.a;
        int i1 = gw1.b;
        int j1 = gw1.c;
        int k1 = gw1.d;
        int l1 = (int)gd.e(l - d.e.m);
        int i2 = (int)gd.e(j1 - d.e.o);
        if(l1 > i2)
            i2 = l1;
        if(gw1.e == 0)
        {
            if(i2 > 16 || flag)
                e.ac.a(l, i1, j1);
        } else
        if(gw1.e == 2)
            e.ac.a();
        else
        if(gw1.e == 1)
        {
            if(i2 > 16 || flag)
                e.ac.a(l, i1, j1, k1);
        } else
        if(gw1.e == 3)
        {
            double d2 = e.k - ((double)l + 0.5D);
            double d3 = e.l - ((double)i1 + 0.5D);
            double d4 = e.m - ((double)j1 + 0.5D);
            double d5 = d2 * d2 + d3 * d3 + d4 * d4;
            if(d5 < 256D)
                e.a.b(((hh) (new eo(l, i1, j1, ((du) (d.e))))));
        }
        d.e.w = false;
    }

    public void a(ez ez1)
    {
        boolean flag = d.e.w = d.f.g(e.ap);
        int l = ez1.b;
        int i1 = ez1.c;
        int j1 = ez1.d;
        int k1 = ez1.e;
        int l1 = (int)gd.e(l - d.e.m);
        int i2 = (int)gd.e(j1 - d.e.o);
        if(l1 > i2)
            i2 = l1;
        if(i2 > 16 || flag)
        {
            gj gj1 = new gj(ez1.a);
            e.ac.a(((ex) (e)), ((du) (d.e)), gj1, l, i1, j1, k1);
        }
        e.a.b(((hh) (new eo(l, i1, j1, ((du) (d.e))))));
        d.e.w = false;
    }

    public void a(java.lang.String s)
    {
        a.info((new StringBuilder()).append(e.ap).append(" lost connection: ").append(s).toString());
        d.f.c(e);
        c = true;
    }

    public void a(hh hh)
    {
        a.warning((new StringBuilder()).append(((java.lang.Object) (((java.lang.Object)this).getClass()))).append(" wasn't prepared to deal with a ").append(((java.lang.Object) (((java.lang.Object) (hh)).getClass()))).toString());
        c("Protocol error, unexpected packet");
    }

    public void b(hh hh)
    {
        b.a(hh);
    }

    public void a(fp fp1)
    {
        int l = fp1.b;
        if(l == 0)
            e.ai.a[e.ai.d] = null;
        else
            e.ai.a[e.ai.d] = new gj(l);
        d.k.a(((df) (e)), ((hh) (new fp(e.c, l))));
    }

    public void a(k k1)
    {
        double d1 = (double)k1.b / 32D;
        double d2 = (double)k1.c / 32D;
        double d3 = (double)k1.d / 32D;
        fh fh1 = new fh(((du) (d.e)), d1, d2, d3, new gj(k1.h, k1.i));
        fh1.n = (double)k1.e / 128D;
        fh1.o = (double)k1.f / 128D;
        fh1.p = (double)k1.g / 128D;
        fh1.ac = 10;
        d.e.a(((df) (fh1)));
    }

    public void a(az az1)
    {
        java.lang.String s = az1.a;
        if(s.length() > 100)
        {
            c("Chat message too long");
            return;
        }
        s = s.trim();
        for(int l = 0; l < s.length(); l++)
            if(" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_'abcdefghijklmnopqrstuvwxyz{|}~\u2302\307\374\351\342\344\340\345\347\352\353\350\357\356\354\304\305\311\346\306\364\366\362\373\371\377\326\334\370\243\330\327\u0192\341\355\363\372\361\321\252\272\277\256\254\275\274\241\253\273".indexOf(((int) (s.charAt(l)))) < 0)
            {
                c("Illegal characters in chat");
                return;
            }

	if(!(SMPAdmin.getInstance(d).parseChatCommand(new Player(e), s)))
	{
        if(s.startsWith("/"))
        {
            d(s);
        } else
        {
            s = (new StringBuilder()).append("<").append(e.ap).append("> ").append(s).toString();
            a.info(s);
            d.f.a(((hh) (new az(s))));
        }
	}
    }

    private void d(java.lang.String s)
    {
        if(s.toLowerCase().startsWith("/me "))
        {
            s = (new StringBuilder()).append("* ").append(e.ap).append(" ").append(s.substring(s.indexOf(" ")).trim()).toString();
            a.info(s);
            d.f.a(((hh) (new az(s))));
        } else
        if(s.toLowerCase().startsWith("/tell "))
        {
            java.lang.String as[] = s.split(" ");
            if(as.length >= 3)
            {
                s = s.substring(s.indexOf(" ")).trim();
                s = s.substring(s.indexOf(" ")).trim();
                s = (new StringBuilder()).append("\2477").append(e.ap).append(" whispers ").append(s).toString();
                a.info(s);
                d.f.a(((hh) (new az(s))));
            }
        } else
        if(s.toLowerCase().equalsIgnoreCase("/home"))
        {
            a.info((new StringBuilder()).append(e.ap).append(" returned home").toString());
            int l = d.e.d(d.e.m, d.e.o);
            a((double)d.e.m + 0.5D, (double)l + 1.5D, (double)d.e.o + 0.5D, 0.0F, 0.0F);
        } else
        if(s.toLowerCase().equalsIgnoreCase("/iron"))
        {
            if(net.minecraft.server.MinecraftServer.b.containsKey(((java.lang.Object) (e.ap))))
            {
                a.info((new StringBuilder()).append(e.ap).append(" failed to iron!").toString());
                b(((hh) (new az("\247cYou can't /iron again so soon!"))));
            } else
            {
                net.minecraft.server.MinecraftServer.b.put(((java.lang.Object) (e.ap)), ((java.lang.Object) (java.lang.Integer.valueOf(6000))));
                a.info((new StringBuilder()).append(e.ap).append(" ironed!").toString());
                for(int i1 = 0; i1 < 4; i1++)
                    e.a(new gj(eu.m, 1));

            }
        } else
        if(s.toLowerCase().equalsIgnoreCase("/wood"))
        {
            if(net.minecraft.server.MinecraftServer.b.containsKey(((java.lang.Object) (e.ap))))
            {
                a.info((new StringBuilder()).append(e.ap).append(" failed to wood!").toString());
                b(((hh) (new az("\247cYou can't /wood again so soon!"))));
            } else
            {
                net.minecraft.server.MinecraftServer.b.put(((java.lang.Object) (e.ap)), ((java.lang.Object) (java.lang.Integer.valueOf(6000))));
                a.info((new StringBuilder()).append(e.ap).append(" wooded!").toString());
                for(int j1 = 0; j1 < 4; j1++)
                    e.a(new gj(fa.y, 1));

            }
        } else
        if(d.f.g(e.ap))
        {
            java.lang.String s1 = s.substring(1);
            a.info((new StringBuilder()).append(e.ap).append(" issued server command: ").append(s1).toString());
            d.a(s1, ((ea) (this)));
        } else
        {
            java.lang.String s2 = s.substring(1);
            a.info((new StringBuilder()).append(e.ap).append(" tried command: ").append(s2).toString());
        }
    }

    public void a(o o1)
    {
        if(o1.b == 1)
            e.y();
    }

    public void a(ie ie1)
    {
        b.a("Quitting");
    }

    public int b()
    {
        return b.d();
    }

    public void b(java.lang.String s)
    {
        b(((hh) (new az((new StringBuilder()).append("\2477").append(s).toString()))));
    }

    public java.lang.String c()
    {
        return e.ap;
    }

    public static java.util.logging.Logger a = java.util.logging.Logger.getLogger("Minecraft");
    public ay b;
    public boolean c;
    private net.minecraft.server.MinecraftServer d;
    private dv e;
    private int f;
    private double g;
    private double h;
    private double i;
    private boolean j;

}
